# -*- coding: utf-8 -*-
import math


def print_love_shape(head_min_width: int = 3, head_reduce_step: int = 1, waist_max_width: int = 19,
                     waist_reduce_step: int = 2):
    """ 打印爱心形状 """
    char1, char2 = '1,', '0,'
    lines = []

    if not waist_max_width & 1:
        raise ValueError('爱心的腰围不能是双数')

    # 上半部分
    for x in range(head_reduce_step, int(waist_max_width - 1 / 2), head_reduce_step):
        char1_width = math.ceil(((waist_max_width - 1) / 2) - x * 2)
        if char1_width <= head_min_width:
            break
        half = '{0}{1}{0}'.format(char2 * x, char1 * char1_width)
        lines.append(half + char2 + half)
    lines.reverse()

    # 中间部分
    lines.append(char1 * waist_max_width)

    # 下半部分
    for x in range(0, waist_max_width, waist_reduce_step):
        lines.append('{0}{1}{0}'.format(char2 * x, char1 * (waist_max_width - x * 2)))
        if (waist_max_width - x * 2) == 3:
            x += 1
            lines.append('{0}{1}{0}'.format(char2 * x, char1 * (waist_max_width - x * 2)))
            break
        elif (waist_max_width - x * 2) == 1:
            break

    print('\n'.join(lines))


if __name__ == '__main__':
    print_love_shape(head_min_width=3, head_reduce_step=1, waist_max_width=19, waist_reduce_step=1)
